import 'package:flutter/material.dart';

class LoginPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(title: Text("登录"),centerTitle: true,),
      body: OutlinedButton(onPressed: ()  {
        Navigator.of(context).pushNamed("menu",arguments: "菜单").then((value) => print(value));
        // var result= Navigator.of(context).push(
        //   MaterialPageRoute(
        //     builder: (context){
        //       return MenuPage();
        //     },
        //     maintainState: false,
        //     fullscreenDialog: true,
        //     settings: RouteSettings(
        //       name: "login",
        //       arguments: {"name":"adidas"}
        //     )
        //   )
        // ).then((value) => print(value));
        //print(result);
      },
        child: Text("登录"),
      style: ButtonStyle(
        backgroundColor:  MaterialStateProperty.resolveWith((states) {
          //设置按下时的背景颜色
          if (states.contains(MaterialState.pressed)) {
            return Colors.blue[200];
          }
          //默认不使用背景颜色
          return null;
        }),
      ),),
    );
  }
}

class MenuPage extends StatelessWidget {

  //final String title;

  //const MenuPage({Key? key,required this.title}):super(key:key);

  @override
  Widget build(BuildContext context) {

    dynamic arguments= ModalRoute.of(context)!.settings.arguments;


    // TODO: implement build
    return Scaffold(
      appBar: AppBar(title: Text("     "+arguments.toString()),centerTitle: true,),
    body: OutlinedButton(
      onPressed: (){
        Navigator.of(context).pop({"name":"你好"});
      },
      child: Text("返回"),
    ),
    );
  }
}
